﻿/// <reference path="../../../Ext-4.1.1a/ext-all.js" />
/**
 * @author dpyang
 * @describe 用户管理视图
 */
Ext.define('WeCompany.view.Users.View', {
    extend: 'Ext.grid.Panel',
    alias: 'widget.usersview',
    requires: ["Ext.ux.CheckColumn"],
    title: '用户管理',
    id: 'usersView',
    store: 'Users',
    border: false,
    selType: "checkboxmodel",//设置复选框
    selModel: { checkOnly: false, mode: "MULTI" },//复选项,允许多选
    initComponent: function () {
        var me = this;

        me.rowEditing = Ext.create('Ext.grid.plugin.RowEditing', {
            autoCancel: false,
            saveBtnText: '保存',
            cancelBtnText: '取消',
            errorText: '错误',
            dirtyText: '你确认保存?'
        })

        me.plugins = [me.rowEditing]
        
        me.columns = [{
            text: '用户名',
            editor: {
                allowBlank: false
            },
            dataIndex: 'UserName',
            flex: 1
        }, {
            text: '电子邮件',
            dataIndex: 'Email',
            editor: {
                allowBlank: false,
                vtype: 'email'
            },
            flex: 1
        }, {
            text: '角色',
            dataIndex: 'Roles',
            editor: {
                xtype: 'combo',
                store: 'Roles',
                multiSelect: true,
                allowBlank: false,
                editable: false,
                emptyText: "请选择角色",
                forceSelection: true
            },
            flex: 1
        }, {
            xtype: 'datecolumn',
            text: '创建日期',
            dataIndex: 'CreationDate',
            format: 'Y-m-d H:i:s',
            width: 150
        }, {
            xtype: 'datecolumn',
            text: '最后登录日期',
            dataIndex: 'LastLoginDate',
            format: 'Y-m-d H:i:s',
            width: 150
        }, {
            text: '是否锁定',
            dataIndex: 'IsApproved',
            xtype: 'checkcolumn',
            width: 50
        }]
        me.tbar = {
            xtype: "pagingtoolbar",
            pageSize: 50,
            displayInfo: true,
            editor: {
                xtype: 'checkbox',
                cls: 'x-grid-checkheader-editor'
            },
            store: me.store,
            items: ['-', {
                iconCls: "user-add",
                tooltip: '添加用户',
                text: '添加',
                id: "buttonUserAdd"
            }, {
                iconCls: "user-delete",
                tooltip: '删除用户',
                text: '删除',
                id: "buttonUserDelete",
                disabled: true
            }, '-', {
                text: "重置密码",
                text: '重置',
                id: "buttonUserResetPassword",
                disabled: true
            }],
        }

        

        me.bbar = ['双击用户可进入编辑状态，用户密码默认为“123456”。重置密码可将用户密码重置为“123456”。']
        me.callParent(arguments);
    }
});